import { defineStore } from "pinia";
import { get, post } from "@/utils/request";
import {ref} from 'vue'

export const useMentorSituationStore = defineStore('mSituation', () => {
  // 学业情况进行中表单数据
  let mSProceedData = ref([])
  const mSProceedRequest = async (name,grade,pageNum,pageSize) => {
    try {
      const response = await get('/teacher/student/questionnaire/underway',{
        name:name,
        grade:grade,
        pageNum:pageNum,
        pageSize:pageSize
      })
      // if(response.code = 200){
        mSProceedData.value = response.data.list
      // }
    } catch (error) {
      console.error(error)
    }
  }

  // 学业情况未完成的审核通过
  const mSPDetailPassRequest = async (questionnaireId) => {
    try {
      const response = await post('/teacher/student/questionnaire/state',{
        questionnaireId:questionnaireId,
        state:'审核通过'
      })
    } catch (error) {
      console.error(error)
    }
  }
  // 学业情况未完成的审核未通过
  const mSPDetailFallRequest = async (questionnaireId) => {
    try {
      const response = await post('/teacher/student/questionnaire/state',{
        questionnaireId:questionnaireId,
        state:'审核失败'
      })
    } catch (error) {
      console.error(error)
    }
  }


  // 学业情况已完成表单数据
  let mSFinishData = ref([])
  const mSFinishRequest = async (name,studyYear,grade,pageNum,pageSize) => {
    try {
      const response = await get('/teacher/student/questionnaire/over',{
        name:name,
        studyYear:studyYear,
        grade:grade,
        pageNum:pageNum,
        pageSize:pageSize
      })
        mSFinishData.value = response.data.list
    } catch (error) {
      console.error(error)
    }
  }

  // 表单详情页数据
  let mSDetailData = ref({})
  const msDetailRequest = async(questionnaireId) => {
    try {
      const response = await get('/teacher/student/questionnaire',{
        questionnaireId:questionnaireId
      })
    } catch (error) {
      
    }
  }
  
  return {mSProceedData,mSProceedRequest,mSFinishData,mSFinishRequest,
    mSPDetailPassRequest,mSPDetailFallRequest,mSDetailData,msDetailRequest
  }
})